/* ----------------------------------------------------------------------------
* File: timer_impl.h
*
* Desc: Timer class implementation
*
* Created: 15/08/2011, by Alexey Korshunov
* ---------------------------------------------------------------------------- */
#ifndef _TIMER_IMPL_H_
#define _TIMER_IMPL_H_

#include "error.h"
#include "exception.h"
#include "timer.h"
#include "thread_wrapper.h"

namespace Common
{
	class TimerImpl 
		: public Timer
		, public ThreadWrapper
	{
	public:
		explicit TimerImpl(const TimerParams& params)
			throw(Exception);
		~TimerImpl();

		// Timer implementation
		virtual Error Start();
		virtual Error Stop();

		// ThreadWrapper implementation
		virtual Error Run();

	private:
		Error CheckParams(const TimerParams& params)
			throw(Exception);
		void PeriodicPulse();
		TimerParams m_Params;
		HANDLE m_StartEvent;
		HANDLE m_StopEvent;
	};
}

#endif // _TIMER_IMPL_H_